﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using DG.Tweening;
using UnityEngine.SceneManagement;

public class StartLoginManager : UIBase
{
    public GameObject signPanel;
    public Button exitBtn;
    public Button panelBtn;
    int upOrdown=300;
    public bool isConcc;
    public GameObject bgMove;
    public GameObject[] bgs;
    public GameObject Sun;

    private void Awake()
    {
        SceneDataManager.sceneName = "LoadingScene";
    }
    void Start()
    {
        LoginInit();
    }

    // Update is called once per frame
    void Update()
    {
        if (isConcc) {
            isConcc = false;
            LoginScucc();
        }
    }
    public void LoginInit() {
        exitBtn.onClick.AddListener(delegate ()
        {
            QuitGame();
        });
        panelBtn.onClick.AddListener(delegate ()
        {
            signPanel.transform.DOMoveY(upOrdown,1f);
            upOrdown *= -1;
        });
    }
    public void LoginScucc() {
        foreach (GameObject obj in bgs) {
            obj.GetComponent<Image>().DOColor(new Color(1, 1, 1, 1), 2f);
        }
        bgMove.GetComponent<Image>().DOColor(new Color(0, 0, 0, 0), 0.5f);
        Sun.transform.DOMove(new Vector3(800, 500, 0), 2.5f);
        Invoke("BlackOut", 2.5f);
        //加载场景
        Invoke("ReloadScene", 3.5f);
    }
    public void ReloadScene() {
        GetComponent<SceneLoadManager>().StartLoad("MainScene");
    }
}
